package hihocoder;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

/**
 * 
 */

/**
 * @author zhongfang
 *
 */
public class AWall {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		HashMap<Integer, Integer> hMap=new HashMap<>();
		for (int i = 0; i < N; i++) {
			int C=scanner.nextInt();
			int x=0;
			for (int j = 0; j < C-1; j++) {
				x+=scanner.nextInt();
				if(hMap.containsKey(x)){
					int curCount=hMap.get(x);
					hMap.put(x, curCount+1);
				}else {
					hMap.put(x, 1);
				}
			}
			scanner.nextInt();//最后的总宽度不算
		}
		int maxCount=0;
		for (Integer entry : hMap.values()) {
			if(entry>maxCount){
				maxCount=entry;
			}
		}
		System.out.println(N-maxCount);
	}
}
